<?php

namespace addons\csmonline\controller;

use addons\csmonline\library\CsmFrontend;
use addons\csmonline\library\CsmonlineCron;
use addons\csmonline\library\CI_User_agent;

//http://127.0.0.1/fastadmin_plugin_csmmeet/public/addons/csmonline/Crontab/index
class Crontab extends CsmFrontend
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    public function _initialize()
    {
        parent::_initialize();

        if (!$this->request->isCli()) {
            $this->error('只允许在终端进行操作!');
        }

    }
    
    public function index()
    {
        return;
    }

    public function run()
    {
        CsmonlineCron::crononedate(date("Y-m-d", time()), true);
        CsmonlineCron::crononedate(date("Y-m-d", strtotime("-1 day")), true);
        CsmonlineCron::crononedate(date("Y-m-d", strtotime("-2 day")), true);
        CsmonlineCron::crononedate(date("Y-m-d", strtotime("-3 day")), true);

        return "Execute completed!\n";
    }

}
